﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using _3Dshower;
namespace UnitTestProject1
{
    [TestClass]
    public class TestPlane
    {
        [TestMethod]
        public void Plane_cal()
        {
            //不显示平面
            plane pl=new plane();
            Point[] points = new Point[4] { new Point(0,0,0), 
                                        new Point(1.2,1.2,0),
                                        new Point(1.2,1.2,1.2), 
                                        new Point(0,0,1.2) };
            line[] lines = new line[4] { new line(points[0],points[1]),
                                          new line(points[2],points[1]),
                                          new line(points[2],points[3]),
                                        new line(points[3],points[0])};
            pl.setBounder(lines);
            Assert.IsTrue(pl.pointDeep(new Point(0.5,0.5,0.5))==null);
            Assert.IsTrue(pl.pointDeep(new Point(0.5, 0.5, 3)) == null);
        }
        [TestMethod]
        public void Plane_cal2()
        {
            //显示平面
            plane pl = new plane();
            Point[] points = new Point[4] { new Point(0,0,0), 
                                        new Point(0,1.2,1.2),
                                        new Point(1.2,1.2,1.2), 
                                        new Point(1.2,0,0) };
            line[] lines = new line[4] { new line(points[0],points[1]),
                                          new line(points[2],points[1]),
                                          new line(points[2],points[3]),
                                        new line(points[3],points[0])};
            pl.setBounder( lines);
            Assert.IsTrue(pl.pointDeep(new Point(0.5, 0.5)) ==0.5);
            Assert.IsTrue(pl.pointDeep(new Point(3,5)) == null);
            Assert.IsTrue(pl.pointDeep(new Point(1, 0.8)) == 0.8);
        }
        [TestMethod]
        public void Plane_cal3()
        {
            //显示平面
            plane pl = new plane();
            Point[] points = new Point[4] { new Point(0,0,1), 
                                        new Point(0,1.2,1),
                                        new Point(1.2,1.2,1), 
                                        new Point(1.2,0,1) };
            line[] lines = new line[4] { new line(points[0],points[1]),
                                          new line(points[2],points[1]),
                                          new line(points[2],points[3]),
                                        new line(points[3],points[0])};
            pl.setBounder(lines);
            Assert.IsTrue(pl.pointDeep(new Point(0.5, 0.5)) ==1);
            Assert.IsTrue(pl.pointDeep(new Point(3, 5)) == null);
            Assert.IsTrue(pl.pointDeep(new Point(1, 0.8)) == 1);
        }
        [TestMethod]
        public void SimpleTest()
        {
            double? d = null;
            Assert.IsFalse(d>1);
            Assert.IsFalse(d <1);

        }
    }
}
